﻿Option Infer On
Imports System
Imports System.Runtime.CompilerServices
Imports System.Reflection
Imports System.Collections
<AttributeUsage(AttributeTargets.Assembly)> _
Public Class AssemblyBuildString
    Inherits Attribute
    Private Shared buildSVar As String
    Public Sub New(ByVal buildString As String)
        buildSVar = buildString
    End Sub
    Public Shared ReadOnly Property BuildString() As String
        Get
            Return buildSVar
        End Get
    End Property

End Class
Module BuildString
    <Extension()> _
    Public Function BuildString(ByVal Ver As Version) As String
        Dim nvc = GetAssemblyAttribs(Assembly.GetExecutingAssembly)
        Dim A = nvc.Get("BuildString")
        Return A
    End Function
    Private Function GetAssemblyAttribs(ByVal a As Reflection.Assembly) As Specialized.NameValueCollection
        Dim attribs() As Object
        Dim attrib As Object
        Dim Name As String
        Dim Value As String
        Dim nvc As New Specialized.NameValueCollection
        attribs = a.GetCustomAttributes(False)
        For Each attrib In attribs
            Name = attrib.GetType().ToString()
            Value = ""
            Select Case Name
                Case "mchatstart.AssemblyBuildString"
                    Name = "BuildString"
                    Value = AssemblyBuildString.BuildString.ToString
            End Select
            If Value <> "" Then
                If nvc.Item(Name) = "" Then
                    nvc.Add(Name, Value)
                End If
            End If
        Next
        Return nvc
    End Function
End Module